<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script>
$('a[data-typeid="20"]').addClass("am-btn-primary");
var queryParams = {};
var tables = $('#dataTables').DataTable({
    "sAjaxSource" : '{{ urlfor "GspController.ProductsDataGrid"}}'
    ,"bLengthChange": false
    ,"fnServerData" : function(sSource, aoData, fnCallback) {
        queryParams = checkQueryTableData(aoData);
        $.post(sSource, JSON.stringify(queryParams),function(resp) {
            fnCallback(resp);
        },'json')
    }
    ,order:[]
    ,columns: [
        {render:function(data, type, full, meta) {
                return '<input type="checkbox" class="selectOne" value="' + full.Id + '" name="select_id[]">';
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return productTypeidName(full.TypeId);
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
            return full.BrandName;
        }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Name;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.ColourNumber;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Spec;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.CastAway;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.ShelfLife;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.RegistrationId;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Unit;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Manufacturer;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.ProducingArea;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.RegistrationId;
            }, "bSortable": false}
    ]
    ,"aLengthMenu":[20, 50, 100, 200]
	,'bLengthChange': true
    ,"serverSide": true
    ,"bPaginate" : true
    ,"bFilter" : false	//是否启动过滤、搜索功能
    ,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
    ,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示
});

$("#query-submit").bind("click", function () { //点击按钮 触发table重新请求服务器
    $("#dataTables").dataTable().fnDraw(false);
    return false;
});
$('.selectAll').click(function () {
    if ($(this).prop('checked') != false) {
        $('.selectOne').prop('checked', true);
    } else {
        $('.selectOne').prop('checked', false);
    }
});
$('#save-quality').click(function(){
    var select_id =  $('.selectOne:checked');
    if(select_id.length<=0) {
        layer.alert('请选择建档商品');return false;
    }
    $.post('{{ urlfor "GspController.QualityInsert" }}', $('#saveform').serialize(), function (res) {
        if(res.code == 1) {
            layer.alert(res.msg);return false;
        }
        parent.dialogCallBack();
    }, 'json');
    return false;
});

</script>